package com.ruoyi.information.controller.back;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.information.domain.back.UserStatisticsBack;
import com.ruoyi.information.service.back.IUserStatisticsBackService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 用户统计Controller
 *
 * @author ruoyi
 * @date 2023-05-10
 */
@RestController
@RequestMapping("/userStatisticsBack")
public class UserStatisticsBackController extends BaseController
{
    @Autowired
    private IUserStatisticsBackService userStatisticsService;

    /**
     * 查询用户统计列表
     */
    @RequiresPermissions("information:userStatistics:list")
    @GetMapping("/list")
    public TableDataInfo list(UserStatisticsBack userStatistics)
    {
        startPage();
        List<UserStatisticsBack> list = userStatisticsService.selectUserStatisticsList(userStatistics);
        return getDataTable(list);
    }

    /**
     * 导出用户统计列表
     */
    @RequiresPermissions("information:userStatistics:export")
    @Log(title = "用户统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserStatisticsBack userStatistics)
    {
        List<UserStatisticsBack> list = userStatisticsService.selectUserStatisticsList(userStatistics);
        ExcelUtil<UserStatisticsBack> util = new ExcelUtil<UserStatisticsBack>(UserStatisticsBack.class);
        util.exportExcel(response, list, "用户统计数据");
    }

    /**
     * 获取用户统计详细信息
     */
    @RequiresPermissions("information:userStatistics:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userStatisticsService.selectUserStatisticsById(id));
    }

    /**
     * 新增用户统计
     */
    @RequiresPermissions("information:userStatistics:add")
    @Log(title = "用户统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserStatisticsBack userStatistics)
    {
        return toAjax(userStatisticsService.insertUserStatistics(userStatistics));
    }

    /**
     * 修改用户统计
     */
    @RequiresPermissions("information:userStatistics:edit")
    @Log(title = "用户统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserStatisticsBack userStatistics)
    {
        return toAjax(userStatisticsService.updateUserStatistics(userStatistics));
    }

    /**
     * 删除用户统计
     */
    @RequiresPermissions("information:userStatistics:remove")
    @Log(title = "用户统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userStatisticsService.deleteUserStatisticsByIds(ids));
    }
}
